package net.gagnat.android.trackit.service;

import net.gagnat.android.trackit.db.DatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteOpenHelper;

public abstract class AbstractDbManager {

	protected SQLiteOpenHelper mOpenHelper;

	protected AbstractDbManager(Context context) {
		mOpenHelper = new DatabaseHelper(context);
	}

	protected String getString(Cursor cursor, String nameColumn) {
		return cursor.getString(cursor.getColumnIndex(nameColumn));
	}

	protected Long getLong(Cursor cursor, String idColumn) {
		return cursor.getLong(cursor.getColumnIndex(idColumn));
	}

	protected Long getMilliseconds(Cursor cursor, String idColumn) {
		long milliseconds = cursor.getLong(cursor.getColumnIndex(idColumn));
		return milliseconds == 0 ? null : milliseconds;
	}

}
